class OrderIdGenerator(object):
  def __init__(self):
    self._order_counter = 0
    self._internal_counter = 0
    self._foreign_counter = 0

  @property
  def order_counter(self):
    return self._order_counter

  @property
  def internal_counter(self):
    return self._internal_counter

  def gen_order_id(self, is_foreign=False):
    self._order_counter += 1
    if is_foreign:
      self._foreign_counter += 1
    else:
      self._internal_counter += 1
    assert self._internal_counter + self._foreign_counter == self._order_counter, (
        self._internal_counter, self._foreign_counter, self._order_counter)
    prefix = 'epl' if is_foreign else 'pl'
    order_id = '%s_%d' % (prefix, self._order_counter)
    return order_id
